<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/11
 * Time: 20:12
 */
require S_ROOT . 'source/newjpush/autoload.php';
require_once(S_ROOT."source/newjpush/src/JPush/Client.php");

//用户签到提醒推送
$app_key = JIGUANGAPPKEY;
$master_secret = JIGUANGMASTERSECRET;
$client = new Client($app_key, $master_secret);

$sql = "select uid,pt from tttj.sign_remind";
$list = getarrrecord($sql);
foreach ($list as $k => $v) {
    if ($v['pt'] == 1) {
        $device = 'android';
        $pttype['pt'] = '1';
    } else {
        $device = 'ios';
        $pttype['pt'] = '2';
    }
    $content = '天天特价10点签到提醒';
    try {
        $result = $client->push();
        $result->setPlatform($device);
        $result->addAlias($v['uid']);
        $result->setNotificationAlert($content);
        if ($pttype['pt'] == 1) {
            $result->androidNotification($content, array('title' => '天天特价', 'builder_id' => 1, 'extras' => array()));
        } else {
            $result->iosNotification($content, array('sound' => 'sound', 'badge' => '+1', 'content-available' => null, 'mutable-content' => null, 'category' => null, 'extras' => array()));
        }
        $result->setOptions(100000, 86400, null, false);
        $result->send();
    } catch (Exception $e) {
        echojson('操作成功', 1, $datas);
    }
}


function objtoarray1($obj) {
    if (is_object ( $obj )) {
        $obj = ( array ) $obj;
    }
    if ($obj)
        foreach ( $obj as $k => $o ) {
            if (is_object ( $o ) || is_array ( $o )) {
                $obj [$k] = objtoarray ( $o );
            }
        }
    return $obj;
}


?>